package evo.springboot.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import evo.springboot.model.Student;
import evo.springboot.service.StudentService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class StudentController {

    @Reference(interfaceClass = StudentService.class,version = "1.0.0",check = false)
    private StudentService studentService;

    @RequestMapping(value = "/query/{id}")
    public ModelAndView query(@PathVariable("id") Integer id){
        Student stu = studentService.queryId(id);
        ModelAndView mv = new ModelAndView();
        mv.addObject("stu",stu);
        mv.setViewName("stuView");
        return mv;
    }

    @RequestMapping(value = "/queryAll")
    public @ResponseBody Object query(){
        Integer result = studentService.queryAll();
        return "总人数为："+result;
    }
}
